﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace TrainingsApp.Model {
    /// <summary>
    ///UserContext 的摘要说明
    /// </summary>
    public class UserContext {

        /// <summary>
        /// 用户ID
        /// </summary>
        public long UserID {
            get;
            set;
        }

        /// <summary>
        /// 用户登录帐号
        /// </summary>
        public string UserName {
            get;
            set;
        }

        /// <summary>
        /// 学工号
        /// </summary>
        public string StuCode {
            get;
            set;
        }

        /// <summary>
        /// 姓名
        /// </summary>
        public string RealName {
            get;
            set;
        }

        /// <summary>
        /// 登录时间
        /// </summary>
        public DateTime LoginTime {
            get;
            set;
        }

        /// <summary>
        /// 身份证
        /// </summary>
        public string IdentityCard {
            get;
            set;
        }

        /// <summary>
        /// 手机
        /// </summary>
        public string Mobile {
            get;
            set;
        }

        /// <summary>
        /// 邮箱
        /// </summary>
        public string Email {
            get;
            set;
        }

        /// <summary>
        /// 用户来源
        /// </summary>
        public Int16 UserSource { get; set; }

        public UserType UserType { get; set; }

        /// <summary>
        /// 当前页面的权限
        /// </summary>
        public T_FUNCTION_Entity CurrentPermission {
            get;
            set;
        }

        /// <summary>
        /// 用户角色列表
        /// </summary>
        public List<T_ROLE_Entity> Roles {
            get;
            set;
        }

        public List<T_FUNCTION_Entity> FunctionRights {
            get;
            set;
        }

        public override string ToString() {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < Roles.Count; i++) {
                sb.AppendFormat("{0}{1}", Roles[i].ID, i == Roles.Count - 1 ? "" : ",");
            }
            return sb.ToString();
        }
    }
}